/**
 * Created by Jacky
 *
 * brief :
 */

define('ssq/view/Table_A', function(require){
    var Base = require('ssq/view/Base');

    var Helper = require('ssq/Helper');

    return KG.Class.define('ssq.view.Table_A', {
        ParentClass : Base,

        eachNumTpl : function(num){
            num = num || '';
            var ss = num ? Helper.Const.HONG[num] : '';
            return '<dd class="cell" data-num="'+num+'">'+ss+'</dd>';
        },

        getTemplate : function(){
            var rs = '',
                arr1 = [1,2,3,4,5,6],
                arr2 = [20,21,22,23,24,7],
                arr3 = [19,32,33,'',25,8],
                arr4 = [18,31,'','',26,9],
                arr5 = [17,30,29,28,27,10],
                arr6 = [16,15,14,13,12,11];

            rs += [
                '<div class="table-A">',
                    '<div class="title">第{{ssq.id}}期</div>',
                        '<div class="row">'
                ].join('');
            var self = this;
            KG.each(arr1, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr2, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr3, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr4, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr5, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div><div class="row">';
            KG.each(arr6, function(index, num){
                rs += self.eachNumTpl(num);
            });

            rs += '</div></div>';

            return rs;
        },

        initView : function(){
            this.callParent('initView');
            var self = this;
            this.ssq.eachHong(function(num){
                self.setHong(num);
            });
        },

        setHong : function(num){
            var jq = this.elem.find('[data-num="'+num+'"]');
            if(jq.length !== 1) return;

            jq.addClass('red');
        }
    });
});